//
//  GQRankCell.m
//  TingMusic
//
//  Created by sunny on 16/4/18.
//  Copyright © 2016年 sunny. All rights reserved.
//

#import "GQRankCell.h"
#import "GQRankItem.h"
#import "GQRankContenItem.h"
#import "UIImageView+Download.h"
#import <UIImageView+WebCache.h>
@interface GQRankCell ()
@property (weak, nonatomic) IBOutlet UIImageView *picimageView;
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UILabel *album1Label;
@property (weak, nonatomic) IBOutlet UILabel *album2Label;
@property (weak, nonatomic) IBOutlet UILabel *album3Label;

@end

@implementation GQRankCell

- (void)setRankItem:(GQRankItem *)rankItem
{
    _rankItem = rankItem;
    
    [self.picimageView sd_setImageWithURL:[NSURL URLWithString:rankItem.pic_s192] placeholderImage:[UIImage imageNamed:@"default"]];
    
    self.nameLabel.text = rankItem.name;
    [self setupNumber:0 label:self.album1Label];
    [self setupNumber:1 label:self.album2Label];
    [self setupNumber:2 label:self.album3Label];
}

//设置对应的排行榜名次
- (void)setupNumber:(NSInteger)number label:(UILabel *)label
{
    GQRankContenItem *contentItem = self.rankItem.content[number];
    label.text = [NSString stringWithFormat:@"%@-%@",contentItem.album_title,contentItem.author];
}

-(void)setFrame:(CGRect)frame
{
    frame.size.height -= GQGlobalMagin;
    [super setFrame:frame];
}

@end
